package com.zhj.mvc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * 测试模块
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {

    /**
     * Api info
     *
     * @return the api info
     * @since 1.0.0
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("API接口文档")
                .description("测试服务")
                .version("1.0.0")
                .build();
    }

    /**
     * Create rest api
     *
     * @return the docket
     * @since 1.0.0
     */
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("test")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zhj.mvc.controller")) // 这里写的是API接口所在的包位置
                .build();
    }
}
